/**
 *  文件名:DiscoverActivity.java
 *  修改人:lihangjie
 *  创建时间:2015-9-14 上午8:34:57
 */
package com.sharemob.tinchat.modules.home;

import java.util.ArrayList;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.sharemob.tinchat.R;
import com.sharemob.tinchat.base.BaseActivity;
import com.sharemob.tinchat.base.BaseFragment;
import com.sharemob.tinchat.base.Item;
import com.sharemob.tinchat.base.NoScrollListview;
import com.sharemob.tinchat.modules.account.GameActivity;
import com.sharemob.tinchat.modules.account.MyspaceActivity;
import com.sharemob.tinchat.modules.discover.NearbyActivity;

/**
 * 
 * <一句话功能简述>
 *
 * @author lihangjie
 * version [版本号,2015-9-14 上午8:34:57]
 * @see    [相关类/方法]
 * @since  [产品/模块版本]
 *
 */
public class FragmentDiscover extends BaseFragment {
	private NoScrollListview listView=null;
	private String[] names=new String[]{"附近的人","直播间","游戏"};
    private String[] tags=new String[]{"nearby","liveroom","game"};
    private int[] resids=new int[]{R.drawable.icon_nearby,R.drawable.icon_live_room,R.drawable.icon_game_room};
    private ArrayList<Item> list = new  ArrayList< Item>(); 
    
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	     
	}
	
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		  for(int i=0;i<names.length;i++){
	        	 Item item=new Item();
	        	 item.setId(tags[i]);
	        	 item.setIcon(true);
	        	 item.setResid(resids[i]);
	        	 item.setName(names[i]); 
	             list.add(item);
	        }
	        listView= getInitListView(list,R.id.listView_discover);
	}
	
	public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
		return inflater.inflate(R.layout.fragment_discover_tab, container,false);
	}
	public void spaceListEvent(int position){
		 Item item=list.get(position);
		 System.out.println(item.getId());
		 if("nearby".equals(item.getId())){
			  Intent intent = new Intent(); 
             intent.setClass(FragmentDiscover.this.getActivity(),NearbyActivity.class);
             startActivity(intent);
             getActivity().overridePendingTransition(R.anim.activity_open,0);
		 }else if("game".equals(item.getId())){
			  Intent intent = new Intent(); 
             intent.setClass(FragmentDiscover.this.getActivity(),GameActivity.class);
             startActivity(intent);
             getActivity().overridePendingTransition(R.anim.activity_open,0);
			 
		 }else if("liveroom".equals(item.getId())){
//			  	 Intent intent = new Intent(); 
//	             intent.setClass(FragmentDiscover.this.getActivity(),GameActivity.class);
//	             startActivity(intent);
//	             getActivity().overridePendingTransition(R.anim.activity_open,0);
				 
			 }
	}
	protected void keyEventOfListView(int position, int id) {

		switch (id) {
		case R.id.listView_discover:
			spaceListEvent(position);
			break;
		default:
			break;
		}
		

         
	}

}
